/*
 * This class is responsible for creating all the other classes and controlling/ running them in a 
 * orderly fashion. It is also responsible for creating the single SPS object which would be used
 * across the entire program.
 * 
 * 
 * =========== IMPORTANT : TRY TO PUT ALL THREADS INSIDE A CLASS IN A SEPERATE CLASS THREAD. THIS ALLOWS ME TO
 * =========== MANIPULATE THE THREADS EASILY AND DOESNT MIX UP THE THREADS AS HAPPENED IN DDS CW.
 */

public class Controller 
{
	protected volatile Boolean running_jobFeeder = null;
	protected volatile Boolean running_jobHandler = null;
	protected volatile Boolean running_resourceCluster = null;
	
	protected volatile SystemPowerState sps = null;
	protected volatile IPowerUsageData pud = null;
	protected volatile IResourceCluster resourceCluster = null;
	protected IJobFeeder jobFeeder = null;
	protected IJobHandler jobHandler = null;
	
	public Controller()
	{
		running_jobFeeder = new Boolean(true);
		running_jobHandler = new Boolean(true);
		running_resourceCluster = new Boolean(true);
		
		sps = new SystemPowerState();
		pud = new PowerUsageData();
		jobFeeder = new JobFeeder(running_jobFeeder);
		jobHandler = new JobHandler(sps,running_jobHandler,pud);
		resourceCluster = new ResourceCluster();
	}
	
	public static void main(String args[])
	{
		Controller cntrl = new Controller();
		
		cntrl.jobFeeder.assignJobHandlerObject(cntrl.jobHandler);
		
		new Thread(cntrl.jobFeeder).start();
		new Thread(cntrl.jobHandler).start();
				
	}
}
